
import pymysql
from certifi import where

host="localhost"
port=3306
user="root"
password="root"
database="finance"

# 专门处理增，删，改
# def update(sql,param):
def update(sql):
    con = pymysql.connect(host=host,port=port,user=user,password=password,database=database)
    cursor =  con.cursor()
    # cursor.execute(sql,param)
    cursor.execute(sql)
    con.commit()
    cursor.close()
    con.close()

# # 专门处理查询
# def  select(sql,param):
#
#     con = pymysql.connect(host=host,port=port,user=user,password=password,database=database)
#     cursor =  con.cursor()
#     cursor.execute(sql,param)
#     data =  cursor.fetchall()
#     con.commit()
#     cursor.close()
#     con.close()
#     return data


# if __name__=="__main__":
#     # sql = "select * from user where username  = %s"
#     # param = ["lisi"]
#     # print(select(sql,param))
#     # print(len(select(sql,param)))
#     #
#     # sql = "select * from bankcard where userID  = %s and cardBank = %s"
#     # param = [1,"伊朗中央银行"]
#     # print(select(sql,param))
#     # print(len(select(sql,param)))
#     #
#     # sql = "select * from bankcard where userID = %s and balance = %s and defaultl = %s"
#     # param = [8, 997000.00, 1]
#     # print(select(sql,param))
#
#     pre_sql = "insert into bankcard values(710, '中国农业银行', 1, '1234567891548796', 1, 10000.00, 0)"
#     print(update(pre_sql))








